package model;

import com.google.gson.annotations.SerializedName;

public class SystemConfiguration {
	private double somLearningRate;
	@SerializedName("database_name")
	private String dbName;
	private RelationalDatabaseManagementSystem rdbms;
	private TrainingParameters trainingParameters;
	private DetectionParameters detectionParameters;

	public double getSomLearningRate() {
		return somLearningRate;
	}

	public void setSomLearningRate(double somLearningRate) {
		this.somLearningRate = somLearningRate;
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	public RelationalDatabaseManagementSystem getRdbms() {
		return rdbms;
	}

	public void setRdbms(RelationalDatabaseManagementSystem rdbms) {
		this.rdbms = rdbms;
	}

	public TrainingParameters getTrainingParameters() {
		return trainingParameters;
	}

	public void setTrainingParameters(TrainingParameters trainingParameters) {
		this.trainingParameters = trainingParameters;
	}

	public DetectionParameters getDetectionParameters() {
		return detectionParameters;
	}

	public void setDetectionParameters(DetectionParameters detectionParameters) {
		this.detectionParameters = detectionParameters;
	}

	public String getConnectionString() {
		return String.format("jdbc:mysql://%s:%d/%s?user=%s&password=%s",
				getRdbms().getIp(), getRdbms().getPort(), getDbName(),
				getRdbms().getUser(), getRdbms().getPassword());
	}

	public String toString() {
		return String
				.format("DBMS=MYSQL, IP=%s, PORT=%d, DB=%s, USER=%s, PASSWORD=*******, "
						+ "TRAINING_PARAMETERS=[MIN_#_CALLS=%d, PERIOD_STEP_MINUTES=%d], "
						+ "DETECTION_PARAMETERS=[ALERT_THRESHOLD=%.3f], SOM=[LEARNING_RATE=%.3f]",
						rdbms.getIp(),
						rdbms.getPort(),
						dbName,
						rdbms.getUser(),
						// rdbms.getPassword(),
						trainingParameters.getMinimumNumberOfCalls(),
						trainingParameters.getTrainingPeriodStepInMinutes(),
						detectionParameters.getAlertThreshold(),
						somLearningRate);
	}

}
